﻿<%@ Page Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true"
    Inherits="HHMMS.UI.Modules.MaterialDirectory.MaterialDirectoryList" Title="物资目录列表" CodeBehind="MaterialDirectoryList.aspx.cs" %>

<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
    <!-- title -->
</asp:Content>

<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">   
    <!-- 搜索框 -->
	<div class="search" style="margin-top:2px;">        
        <web:search ID="GridSearch" GridViewId="SmartGridView1" runat="server">            
            <SearchConditionTemplate>                                       
                <table cellpadding="0" cellspacing="0" width="95%">
			        <tr>
                        <th>
                            物资编码：
                        </th>
	                    <td>
		                    <asp:TextBox ID="MaterialsNo" Name="MaterialsNo" runat="server" ></asp:TextBox>
	                    </td>
                        <th>
                            物资名称：
                        </th>
	                    <td>
		                    <asp:TextBox ID="MaterialsName" Name="MaterialsName" runat="server"></asp:TextBox>
	                    </td>               
                    </tr>			            
                </table>
            </SearchConditionTemplate>                      
        </web:search>
    </div>

    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
				    物资目录列表
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar"  style="height:30px;">
            <asp:LinkButton runat="server"
                OnClientClick="return openEditor(this, 'Insert');" OnClick="SearchGrid">
                <span>
                    <img alt="" runat="server" src="~/Images/icon_new.gif" style="border: 0px" />新建
                </span>
            </asp:LinkButton>
	    </div>
	    <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="MaterialsNo" DataSourceID="SmartDataSource1" PageSize="10">
                <Columns>            
                    <asp:BoundField DataField="MaterialsNo" HeaderText="物资编码" ItemStyle-Width="130px" SortExpression="MaterialsNo" />
                    <asp:BoundField DataField="MaterialsName" HeaderText="物资名称" SortExpression="MaterialsName" />
                    <asp:BoundField DataField="MaterialsModel" HeaderText="物资规格" SortExpression="MaterialsModel" />                                  
                    <asp:BoundField DataField="unit" HeaderText="单位" SortExpression="unit" />                                  
                    <asp:BoundField DataField="price" HeaderText="单价" SortExpression="price" />      
                     <asp:BoundField DataField="MinNum" HeaderText="库存最低保有量" SortExpression="MinNum" />   
                    <asp:BoundField DataField="KeepDate" HeaderText="使用期限（天）" SortExpression="KeepDate" />                            
                    <asp:TemplateField HeaderText="操作">
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>                                    
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton runat="server" ToolTip="编辑" _MaterialsNo='<%#Eval("MaterialsNo")%>'
                                            ImageUrl="~/images/com/dg_edit.gif" CausesValidation="False" OnClientClick="return openEditor(this, 'Edit');" OnClick="RefreshGrid">
                                        </asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton runat="server" ToolTip="删除" ImageUrl="~/images/com/dg_del.gif" _MaterialsNo='<%#Eval("MaterialsNo")%>'
                                            CausesValidation="False" OnClientClick="return confirm('您确认要删除吗?')" OnClick="DeleteUser">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="MaterialDirectory.list" SelectCountCommand="MaterialDirectory.list.count"
                    DefaultSortExpression="MaterialsNo DESC" SelectCommandAutoPageWrap="true">
            </web:SmartSqlDataSource>
        </div>
	</div>

    <script type="text/javascript">
        function openEditor(_this, action) {
            var url;

            // FormViewMode : Insert/Edit/ReadOnly
            var params = {FormViewMode: action }
            if (action == "Insert") {
                url = "MaterialDirectoryEdit.aspx";
                params.title = "物资目录新增";
            } else if (action == "Edit") {
                url = "MaterialDirectoryEdit.aspx";
                params.title = "物资目录编辑";
                params.MaterialsNo = _this.attributes["_MaterialsNo"].value;
            } 
            var returnValue = showCenterModalDialog(buildUrl(url, params), 620, 300, null);
            return returnValue == "true";
        }       
    </script>

</asp:Content>